package com.qiaofang.applet.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.StringUtils;

/**
 * @author junze.liu
 */
@Getter
@AllArgsConstructor
public enum UserType {

    MINI_PROGRAM("1", "小程序会员"),
    EMPLOYEE("2", "经纪人");

    private String code;

    private String value;

    public static String getValueByCode(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (UserType item : values()) {
            if (item.getCode().equals(code)) {
                return item.getValue();
            }
        }
        return null;
    }

    public static String getCodeByValue(String value) {
        if (StringUtils.isEmpty(value)) {
            return null;
        }
        for (UserType item : values()) {
            if (item.getValue().equals(value)) {
                return item.getCode();
            }
        }
        return null;
    }
}
